//
//  GAKKIBaseTabBarController.m
//  GANGAIKit
//
//  Created by fh on 2019/11/15.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseTabBarController.h"


@interface GAKKIBaseTabBarController ()

@end

@implementation GAKKIBaseTabBarController

- (void)dealloc {
    if (kDebugViewControllerRelease) {
        DBLog(@"\n ~~~~~~+++++++ 控制器 %@ 销毁了 +++++++~~~~~~ \n",[self class])
    }
}

// 配置tabBarItem
- (void)configureTabBarUIWithBaseViewController:(GAKKIBaseNavigationController *)controller imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName title:(NSString *)title tintColor:(UIColor *)tintColor unselectedItemTintColor:(UIColor *)unselectedItemTintColor {
    if (kStringIsEmpty(imageName) || kStringIsEmpty(selectedImageName)) {
        return;
    }
    controller.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    controller.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
//    [UITabBarItem appearance].titlePositionAdjustment  = UIOffsetMake(0, -3);
//    controller.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3);
    controller.tabBarItem.title = title;

    // 适配iOS13导致的bug
    if (@available(iOS 13.0, *)) {
        // iOS 13以上
        self.tabBar.tintColor = tintColor;
        self.tabBar.unselectedItemTintColor = unselectedItemTintColor;
    } else {
        // iOS 13以下
        [controller.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tintColor} forState:UIControlStateSelected];
        [controller.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:unselectedItemTintColor} forState:UIControlStateNormal];
    }
    
}



@end
